package com.cloud.code.牛客网;

import java.util.Scanner;

/**
 * 最长公共子串
 */
public class Test66 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String line1 = scanner.nextLine();
            String line2 = scanner.nextLine();

            if (line1.length() > line2.length()) {
                // 确保s1比较短
                String tmp = line1;
                line1 = line2;
                line2 = tmp;
            }

            int start = 0;
            int end = 1;

            String max = "";
            while (end <= line2.length()){

                String substring = line2.substring(start, end);
                if(line1.contains(substring)){
                    if(max.length() < substring.length()){
                        max = substring;
                    }
                    end ++;
                }else {
                    start ++;
                    end=start+1;
                }

            }

            System.out.println(max);

        }
    }
}
